package com.example.mybatisplus;


import com.example.mybatisplus.entity.User;
import com.example.mybatisplus.mapper.UserMapper;
import com.example.mybatisplus.service.UserService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author lizhien
 * @since 2021-12-20
 */
@RestController
public class BaseController {

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private UserService userService;

    @GetMapping("/base")
    public String getAll() {
        System.out.println(("----- selectAll method test ------"));
        List<User> userList = userMapper.selectList(null);
        userList.forEach(System.out::println);

        User user = new User();

        user.setAge(18);
        user.setEmail("zhangsan@sina.com");
        user.setName("zhangsan");
        userMapper.insert(user);

        return "hello world" + userList;
    }
}
